<!DOCTYPE html>
<html>

<head>
  <title>
    <%= title %>
  </title>
  <link rel='stylesheet' href='/stylesheets/style.css' />
</head>

<body>
  <h1>
    <%= title %>
  </h1>
  <p>Welcome to
    <%= title %>
  </p>
  shell脚本
  <br>
  <textarea id="cmd">

  </textarea>
  <ul id="code"></ul>
  <script src="/axios/dist/axios.min.js"></script>
  <script src="https://cdn.bootcss.com/socket.io/2.0.4/socket.io.js"></script>
  <script>
    window.onload = function () {
      var cmd = document.getElementById('cmd')
      var submit = document.getElementById('submit')
      var code = document.getElementById('code')
      var socket = io.connect('http://localhost:3000');
      let html = ''
      socket.on('result', function (data) {
        console.log(data);
        html = data.html
        code.innerHTML = html
      });
      window.addEventListener('keyup',function (ev) {
        if(ev.keyCode === 13){
          socket.emit('shell', {
            cmd: cmd.value,
            html:html
          });
        }
      })
    }
  </script>
</body>

</html>